﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Code;
using System.Data;
namespace E2_WEBSITE.Code.HINH_ANH
{
    public class HinhAnhDataAccess
    {
        DataProvider m_DataProvider = DataProvider.GlobalDataProvider;
        public List<string> GetListColorByProName(string sProductName)
        {
            List<string> lst = new List<string>();

            string sSql = "select distinct MauSac from HINH_ANH,SAN_PHAM where HINH_ANH.idSanPham = SAN_PHAM.id AND SAN_PHAM.TenSanPham = '" + sProductName+"'";
            DataTable dt = m_DataProvider.ExecuteQueryDataTable(sSql);
            if(dt!=null)
            {
                int iCount = dt.Rows.Count;
                for(int i =0;i<iCount ;i++)
                {
                    lst.Add(dt.Rows[i][0].ToString());
                }
            }
            return lst;
        }
        public int GetHinhAnhIDByColorNameAndProductName(string scolorName,string sProductName)
          {
              int iID = 0;
              string sSql = "select Hinh_Anh.ID from HINH_ANH,SAN_PHAM where HINH_ANH.MauSac = N'" + scolorName + "' and HINH_ANH.idSanPham = SAN_PHAM.id AND SAN_PHAM.TenSanPham = '" + sProductName + "'"; 
              DataTable dt = m_DataProvider.ExecuteQueryDataTable(sSql);
              if (dt != null)
              {
                  if (dt.Rows.Count > 0)
                      iID = int.Parse(dt.Rows[0][0].ToString());
              }
              return iID;
          }
    }
}
